# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=ccache

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=r1359.c5533d6
pkgrel=1
pkgdesc="A compiler cache (mingw-w64)."
arch=('any')
url="http://ccache.samba.org/"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
        "${MINGW_PACKAGE_PREFIX}-zlib")
options=('staticlibs' 'strip')
source=("${_realname}"::"git+git://git.samba.org/ccache.git")
md5sums=('SKIP')

pkgver() {
  cd "$srcdir/$_realname"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${_realname}
  ./autogen.sh
}

build() {
  mkdir -p $srcdir/build-${CARCH} && cd $srcdir/build-${CARCH}
  ../$_realname/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST}
  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make DESTDIR="$pkgdir" install
}
